import request from './request'
//获取首页数据
export const getHomeData = () => request.get('/index/index')



// 获取购物车产品数量
export const GetGoodsCount = () => request.get("/cart/goodscount")


// 加入购物车
export const AddProductToCart = (params) => request.post("/cart/add", params)


// 获取购物车数据
export const GetCartListData = () => request.get("/cart/index")

// 点击切换商品选中状态（含全选）
export const ChangeGoodChecked = ({ isChecked, productIds }) => request({ url: "/cart/checked",method:'post', data: {isChecked,productIds} })


// 步进器
export const StepperChangeData = (data) => request({url:"/cart/update",method:'post',data})


// 购物车删除商品
export const DeleteGood = (productIds) => request({url:"/cart/delete",method:'post', data:{productIds}})
//登录/注册信息
export const toLogin = (username, pwd) => request({
    method: 'post',
    url: '/auth/loginByWeb',
    data: {
        username,
        pwd
    }
})
//获取详情商品数据
export const getShop = (id) => request({
    url: `/goods/detail`,
    params: { id: id },
    method: 'get'
})

// 获取专题数据
export const getSubjectData = (page, size) => request.get('/topic/list', { page, size })
// 获取分类页面的初始数据信息
export const getCategoryInitData = () => request.get('/catalog/index')
// 点击导航栏根据id获取次目录列表
export const getGoodList = (id) => request.get('/catalog/current?id=' + id)
//根据分类获取商品列表
// export const getShopList = (categoryId, page = 1, limit = 9) => request({
//     url: `/goods/list`,
//     params: {
//         categoryId: categoryId,
//         page: page,
//         limit: limit
//     },
//     method: 'get'
// })


//添加购物车
export const addShopCart = (goodsId, productId, number = 1) => request({ url: '/cart/add', method: 'post', data: { goodsId, productId, number } })

//获取购物车产品数据
export const shopCartNumber = () => request.get('/cart/goodscount')

// 搜索关键字获取数据
export const searchData = (data)=>request.get('/goods/list',data)
// 实时搜索功能
export const searchTime = (keyword)=>request({url:`search/helper?keyword=${keyword}`,method:'get'})
//获取搜索框初始数据
export const searchInitData = () => request.get('/search/index')
// 删除历史记录
export const deleteHistory = () => request.post('/search/clearhistory')

